#include <stdio.h>
#include <string.h>
#include <ctype.h>

int Maxlen( char *s1,  char *s2, int len1, int len2) {
	int max = 0;
	int i = 0;
	int j = 0;
	for (i = 0; i < len1; i++) {
		for (j = 0; j < len2; j++) {
			int count = 0;
			while (i + count < len1 && j + count < len2 && tolower(s1[i + count]) == tolower(s2[j + count])) {

				count++;
			}
			if (count > max)
				max = count;
		}
	}

	return max;
}

int main() {
	char s1[101] = {0};
	char s2 [101] = {0};
	fgets(s1, 101, stdin);
	fgets(s2, 101, stdin);
	int len1 = strlen(s1);
	int len2 = strlen(s2);
	if (s1[len1 - 1] == '\n')
		s1[--len1] = '\0';
	if (s2[len2 - 1] == '\n')
		s2[--len2] = '\0';
	int LCS = 0;
	double num = 0;
	int i = 0;

	LCS = Maxlen(s1, s2, len1, len2);
	num = (2.0 * LCS) / (1.0 * (len1 + len2));
	printf("%.3f\n", num);
	return 0;
}